package learnJava.puzzlers;

import java.io.IOException;

public class TryFinallyPuzzlers {
    public static class Indecisive{
        public static void main(String[] args) {
            System.out.println(decision());
        }
        static boolean decision(){
            try {
                return true;
            }finally {
                //try-finally中finally总是在语句离开try时执行
                return false;
            }

        }
    }
    public static class Arcane{
        public static void main(String[] args) {
            Class c = Arcane.class;
        }
    }
    public static class WorkHard{
        public static void main(String[] args) {
            workhard();
            System.out.println("never reach");
        }
        // finally会让vm抛出过多异常，导致出现了无限循环的假象，
        // 其实是vm需要处理一个以光年计的异常量，导致我们无法看到反馈
        public static void workhard(){
            try {
                workhard();
            }finally {
                workhard();
            }
        }
    }
}
